<?php

namespace App\Http\Controllers;

use App\UserModel;
use Illuminate\Http\Request;

class HomeController extends Controller
{
    public function index(Request $request)
    {
        $users = UserModel::all()->toArray();
        foreach ($users as &$user){
            $user['headimg'] = explode(";",$user['headimg']);
            array_pop( $user['headimg']);
        }
        return view("table",compact('users'));
    }

    public function addPage(Request $request)
    {
        $user = null;
        $id = $request->input('id');
        if($id){
            $user = UserModel::find($id)->toArray();
        }
        return view("addPage",compact('user'));
    }
}
